package com.oilsoft.module.main.model.manager
{
	import com.oilsoft.shared.events.LoginEvent;
	import com.oilsoft.shared.constant.LoginConstant;
	import com.oilsoft.shared.vos.User;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;

	public class AuthorizationManager extends EventDispatcher
	{
		// .........................................Properties......................................
		private var _status:String = LoginConstant.LOGUED_OUT;
		[Bindable(Event="statusChange")]
		public function get status():String
		{
			return _status;
		}
		
		//.........................................Methods..........................................
		
		public function login(user:User):Boolean 
		{
			//check hardcoded username and password
			var isLogin:Boolean = (user!=null);
			_status = isLogin ? LoginConstant.LOGUED : LoginConstant.FAILED;
			dispatchEvent( new Event( "statusChange" ) );
			return isLogin;
		}
		
		public function logout():void
		{
			_status = LoginConstant.LOGUED_OUT;
			dispatchEvent( new Event( "statusChange" ) );
		}
	}
}